package ObserverModel;

/**
 * Created by Lenovo on 2017/5/15.
 */
public class ConcreteObserver extends Observer {

    /**
     * 具体观察者
     */

    private String observerState;
    private String name;
    private ConcreteSubject subject;

    public ConcreteObserver(String name, ConcreteSubject subject) {
        this.name = name;
        this.subject = subject;
    }

    public ConcreteSubject getSubject() {
        return subject;
    }

    public void setSubject(ConcreteSubject subject) {
        this.subject = subject;
    }

    /**
     * 实现更新操作
     */
    @Override
    public void Update() {
        observerState = subject.getSubjectState();
        String str = String.format("The observer's state of %s is %s", name, observerState);
        System.out.println(str);
    }
}
